using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cameraP3 : MonoBehaviour
{

    public Transform pursuer;  // 要跟随的目标对象
    public float smoothSpeed = 0.125f;  // 相机移动速度
    public Vector3 offset;  // 相机位置偏移量
    public float rotationSpeed = 1f;  // 相机旋转速度
    private void Start() {
        
    }
    void FixedUpdate()
    {
        //Vector3 desiredPosition = target.position + offset;  // 目标位置
        //Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);  // 平滑移动
        transform.position = transform.position;

        Quaternion targetRotation = Quaternion.LookRotation(pursuer.position - transform.position);  // 目标旋转
        transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);  // 平滑旋转
    }
}
